<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>通过方法获取和设置元素属性</title>
</head>
<body>
    <input type="text" class="类名" id="inputId" name="inputName" value="值" abcc="自定义属性"/>
    <script>
        document.write('<p style="color:red;"><br/><br/><br/>获取任意属性：<br/>语法：元素.getAttribute("属性名")</p>');
        document.write('<br/><br/><br/>通过方法获取元素属性：getAttribute 方法来获取自定义属性。<br/>');
        var z = document.getElementById('inputId').getAttribute('abcc');
        document.write(z + '<br/>');
        document.write('<p style="color:red;"><br/>设置任意属性：<br>语法：元素.setAttribute("属性名","属性值")；</p>');
        var a = document.getElementById('inputId').setAttribute('abcc','修改任意属性值');
        console.log(document.getElementById('inputId'));
    </script>
</body>
</html>